#!/usr/bin/env bash
# 清理服务器tomcat catalina.out 脚本
dir_prefix="/home/logonuser/tomcat-8.5.32-"
dir_suffix="/logs/catalina.out"

tomcat_names=(
"config"
"gateway"
"register"
"admin"
"binding"
"blacklist"
"cashin"
"distribute"
"given"
"image"
"log"
"query"
"upms"
)

# shellcheck disable=SC2068
for name in ${tomcat_names[@]}
do
    log_file_name="${dir_prefix}${name}${dir_suffix}"
    echo "clear tomcat log dir : ${log_file_name}"
    # shellcheck disable=SC2188
    > ${log_file_name}
done

#end

#chmod +x clear_tomcat_log.sh
#crontab -e
#每天的凌晨2点10分
#10 02 * * * /home/logonuser/clear_tomcat_log.sh
#service crond restart